package com.wcity.manage.web.property;

import com.wcity.manage.common.enums.Code;
import com.wcity.manage.dao.dal.model.PageModel;
import com.wcity.manage.dao.model.Block;
import com.wcity.manage.dao.model.NightDuty;
import com.wcity.manage.dao.model.VisitRegister;
import com.wcity.manage.service.property.VisitRegisterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 访问登记
 * Created by chenkelong on 2017/7/18.
 */

@Controller
@RequestMapping("visit")
public class IPropertyVisitRegisterAct {

    @Resource
    private VisitRegisterService visitRegisterService;

    /**
     * 添加访问记录
     * @return
     */
    @RequestMapping ("i_visitregister_add")
    @ResponseBody
    public Map<String,Object> visitregisterAdd (

            int userId,String visitDate,String visisName,String visitPhone,String ownerName,String ownerRoomnum,String visitReason

    ) {

        Map<String,Object> map = new HashMap<>();
        VisitRegister visitRegister = new VisitRegister(visitDate,visisName, visitPhone, ownerName, ownerRoomnum,userId,visitReason);
        try{
            int result = visitRegisterService.VisitRegisterAdd ( visitRegister );
            map.put("result",result);
            map.put("retCode", Code.SUCCESS.getCodeNum());
            map.put("retDesc","请求成功");
        }catch (Exception e){
            e.printStackTrace();
            map.put("err","服务器异常");
        }
        return map;
    }


}
